import path from 'path'
import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/auth/login',
      name: 'Login',
      component: () => import('@/views/auth/authView.vue'),
      meta: {
        title: '登录'
      }
    },
    {
      path: '/',
      name: '/',
      redirect: '/home/discover'
    },
    {
      path: '/home',
      name: 'home',
      component: ()=>import('@/views/home/homeView.vue'), 
      children:[
        {
          path: '/home/discover/:title?',
          name: 'discover',
          component: ()=>import('@/views/discover/discoverView.vue'),
          props:true,
        },
        {
          path:'/home/userInfo/:userId?',
          name: 'userInfoVideo',
          component: ()=>import('@/views/user/userInfoView.vue'),
          props:true,
        },
        {
          path:'/home/follow',
          name: 'follow',
          component: ()=>import('@/views/follow/followView.vue')
        },
        {
          path:'/home/live',
          name: 'live',
          component: ()=>import('@/views/live/liveHomeView.vue')
        },
        {
          path:'/home/presenter',
          name: 'presenter',
          component: ()=>import('@/views/live/presenterView.vue')
        },
        { 
          path:'/home/customer',
          name: 'customer',
          component: ()=>import('@/views/user/customerView.vue')
        },
        {
          path:'/home/vip',
          name: 'vip',
          component: ()=>import('@/views/vip/vipView.vue'),
        },
        {
          path: '/home/auth/apply',
          name: 'ApplyClient',
          component: ()=>import('@/views/auth/applyClientView.vue'),
        },
        {
          path: '/home/orders',
          name: 'MyOrders',
          component: ()=>import('@/views/order/myOrdersView.vue'),
          meta: {
            requiresAuth: true
          }
        },
        {
          path: '/home/payment/:orderStatementId',
          name: 'PaymentWithParams',
          component: ()=>import('@/views/order/paymentView.vue'),
          props: true,
            meta: {
              requiresAuth: true
            }
        }
      ]
    },
    {
      path: '/author',
      name: 'author',
      component: ()=>import('@/views/author/authorView.vue'),
      children:[
        {
          path:'/author/home',
          name: 'authorHome',
          component: ()=>import('@/views/author/authorHomeView.vue')

        },
        {
          path: '/author/works',
          name: 'works',
          component: ()=>import('@/views/author/authorWorksView.vue')
        },
        {
          path: '/author/reviewing',
          name: 'review',
          component: ()=>import('@/views/author/authorReviewView.vue')
        },
        {
          path:'/author/createWork',
          name: 'create',
          component: ()=>import('@/views/author/authorCreateWorkView.vue')
        }
      ]
    },
    {
      path: '/admin',
      name: 'admin',
      component: ()=>import('@/views/admin/adminView.vue'),
      children:[
        {
          path: '/admin/home',
          name: 'adminHome',
          component: ()=>import('@/views/admin/adminHomeView.vue')
        },
        {
          path: '/admin/systemAnswer',
          name: 'systemAnswer',
          component: ()=>import('@/views/admin/adminSystemAnswerView.vue')
        },
        {
          path: '/admin/seekKill',
          name: 'seekKill',
          component: ()=>import('@/views/admin/adminSeekKillView.vue')
        },
        {
          path: '/admin/client',
          name: 'adminClient',
          component: () => import('@/views/admin/adminClientView.vue')
        },
        {
          path: '/admin/orderLog',
          name: 'adminOrderLog',
          component: () => import('@/views/admin/adminOrderLogView.vue')
        },
      ]
    },
    {
      path:'/reviewer',
      name: 'reviewer',
      component: ()=>import('@/views/reviewer/reviewerView.vue'),
      children:[
        {
          path: '/reviewer/home',
          name: 'reviewerHome',
          component: ()=>import('@/views/reviewer/reviewerHomeView.vue')
        },
        {
          path: '/reviewer/reviewing',
          name: 'reviewing',
          component: ()=>import('@/views/reviewer/reviewerReviewingView.vue'),
        }
      ]
    },
    {
      path:'/liveing/:presenterId',
      name: 'liveing',
      component: ()=>import('@/views/live/liveingView.vue'),
      props:true,
    },
    {
      path: '/auth/oauth2/login',
      name: 'OAuth2Login',
      component: ()=>import('@/views/auth/oauth2LoginView.vue'),
      meta: {
        requiresAuth: false
      }
    }
  ]
})

export default router